using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Net;

namespace Quiki.Services
{
    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
    public class FakeFtpClient : IFtpClient
    {
        public ICredentials Credentials
        {
            get; set;
        }

        public string Host
        {
            get; set;
        }

        public int? Port
        {
            get; set;
        }

        public FakeFtpConnection Connection
        {
            get { return connection; }
        }

        public IList<string> RecordedActions
        {
            get { return actions; }
        }

        public void Initialize()
        {
            connection = new FakeFtpConnection(this);
            actions.Clear();
        }

        public IFtpConnection Open()
        {
            return connection;
        }

        public void RecordAction(string action)
        {
            actions.Add(action);
        }

        public void RecordAction(string format, params object[] args)
        {
            actions.Add(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        private FakeFtpConnection connection;
        private List<string> actions = new List<string>();
    }
}